## Goreleaser requires the "--platform" to handle multi-platform builds
# hadolint ignore=DL3029
FROM alpine:3.22.1@sha256:4bcff63911fcb4448bd4fdacec207030997caf25e9bea4045fa6c8c44de311d1 as certs

RUN apk add --no-cache ca-certificates

## Goreleaser requires the "--platform" to handle multi-platform builds
# hadolint ignore=DL3029
FROM scratch

LABEL maintainer="Olivier Vernin <me@olblak.com>, Damien DUPORTAL <damien.duportal@gmail.com>"

# Dynamic labels are defined from the goreleaser configuration ".goreleaser.yaml"
LABEL org.opencontainers.image.authors="Olivier Vernin<me@olblak.com>, Damien DUPORTAL <damien.duportal@gmail.com>"
LABEL org.opencontainers.image.url="https://github.com/updatecli/updatecli/pkgs/container/updatecli"
LABEL org.opencontainers.image.documentation="https://www.updatecli.io/docs/prologue/introduction/"
LABEL org.opencontainers.image.licenses="Apache-2.0"
LABEL org.opencontainers.image.title="Updatecli"
LABEL org.opencontainers.image.description="The gitops automation engine"
LABEL org.opencontainers.image.base.name="ghcr.io/updatecli/updatecli"
LABEL org.opencontainers.image.source https://github.com/updatecli/updatecli

VOLUME /tmp

# Add the ca-certificates package
# This can be done by copying it from an existing minimal Linux distribution image like Alpine
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
COPY --from=certs /etc/ca-certificates /etc/ca-certificates
COPY --from=certs /usr/share/ca-certificates /usr/share/ca-certificates
COPY --from=certs /etc/nsswitch.conf /etc/nsswitch.conf

# Define environment variables to point to the certificates
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt

# Available files only matched against the binaries generated by the builds section
# and packages generated by the nfpms section.
COPY updatecli  /bin/updatecli

ENTRYPOINT ["/bin/updatecli"]
CMD ["help"]
